﻿using Abp.Domain.Entities;
using IntelligentAgriculture.Contracts.Interface;
using IntelligentAgriculture.Domain.Entity;
using IntelligentAgriculture.WebAPI.Application.Command.BreedingWeighCommand;
using IntelligentAgriculture.WebAPI.Application.Command.DepartMentCommand;
using IntelligentAgriculture.WebAPI.Application.CommandHandler.DepartMentCommandHandler;
using MediatR;

namespace IntelligentAgriculture.WebAPI.Application.CommandHandler.BreedingWeighCommandHandler
{
    public class BreedingCreateCommandHandler : IRequestHandler<BreedingWeighCreateCommand, Results<int>>
    {

        private readonly IBreedingWeighService breeingService;
        private readonly ILogger<BreedingCreateCommandHandler> logger;
        public BreedingCreateCommandHandler(IBreedingWeighService breeingService, ILogger<BreedingCreateCommandHandler> logger)
        {
            this.breeingService = breeingService;
            this.logger = logger;
        }

        public async Task<Results<int>> Handle(BreedingWeighCreateCommand request, CancellationToken cancellationToken)
        {

            var result = new Breedingweigh()
            {
                BreedingId = request.BreedingId,
                WeighDate = request.WeighDate,
                EarTag = request.EarTag,
                Weight = request.Weight,
                WeighCategory = request.WeighCategory,
                 
            };

            var list = await breeingService.Add(result);

            return Results<int>.DataResult(list);


        }
    }



}
